#include <iostream>
#include <string>
#include <vector>

using namespace std;

struct Suf{
	int L, p;
	Suf(int L, int p): L(L), p(p) {}
};


void Push(vector<Suf> & v, Suf suf)
{
	if(suf.L <= v.back().L) return;
	if(suf.p == v.back().p && v.back().L >= 2 * v.back().p)
	{
		v.back().L = suf.L;
		return;
	}
	v.push_back(suf); //???
}
vector<char> M[150];
vector< vector<Suf> > allSuff;


void init(string s)
{
	vector<Suf> suf;
	int n = s.length() - 1;
	suf.push_back( Suf(1, 1) );	
	allSuff.push_back(vector<Suf>());
	allSuff.push_back(suf);
	for(int i = 2; i <= n; i++)
	{
		vector<Suf> newSuf;
		newSuf.push_back( Suf(1, 1) );
		if(s[i] == s[i - 1])
			newSuf.push_back( Suf(2, 1) );
		for(int j = 0; j < suf.size(); j++)
		{
			int L = suf[j].L + 2, p = suf[j].p;
			if(s[i] != s[i - L + 1 + p]) p = L - newSuf.back().L;
			if(s[i] != s[i - L + 1]) L -= p;
			Push(newSuf, Suf(L, p));
		}
		suf = newSuf;
		allSuff.push_back(suf);
	}
}


vector<char> doIter(string s, const vector<char> & m)
{
	int n = s.length() - 1;
	vector<char> res, z(n + 1);
	res.reserve(n + 1);
	res.push_back(false);
	res.push_back(m[0]);
	for(int i = 2; i <= n; i++)
	{
		vector<Suf> & suf = allSuff[i];
		bool curPref = false;
		for(int j = 0; j < suf.size(); j++)
		{
			int L = suf[j].L, p = suf[j].p;
			if(L < 3 * p) z[i - L] = m[i - L];
			z[i - L] |= m[i - p - L % p];
			curPref |= z[i - L];
		}
		res.push_back(curPref);
	}
	return res;
}


void main()
{
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	string s;
	int k;
	cin >> s >> k;	
	int n = s.size();
	printf("%s\n", s.c_str());
	s = "#" + s;
	init(s);
	vector<char> m(n + 1, false);
	m[0] = true;
	M[0] = m;
	for(int i = 0; i < k; i++)
	{
		M[i + 1] = m = doIter(s, m);
		for(int i = 1; i <= n; i++)
		{
			printf(m[i] ? "x" : ".");
		}
		printf("\n");
	}
}